import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'

Vue.use(Router)

export default new Router({
  routes: [
    // {
    //   path: '/',
    //   name: 'home',
    //   component: Home
    // },
    {
      path: '/about',
      name: 'about',
      component: () => import('./views/About.vue')
    },
    //后台管理项目
    {
      path: '/llogin',
      name: 'llogin',
      component: () => import('./views/UserLogin/llogin.vue')
    },
    {
      path: '/',
      name: 'lindex',
      component: () => import('./views/PageManagement/lindex.vue'),
      redirect: '/users',
      //路由独享导航守卫
      beforeEnter(to, from, next) {
        next();
        if (window.sessionStorage.getItem('lc_04B')) {
          next()
        } else {
          next('./llogin')
        }
      },
      //二级路由
      children: [
        {
          path: '/users',
          name: 'Users',
          component: () => import('./components/user/users.vue'),
          meta: {
            bread: ['用户管理', '用户列表']
          }
        },
        {
          path: '/reports',
          name: 'Reports',
          component: () => import('./components/data/reports.vue'),
          meta: {
            bread: ['数据统计', '数据报表']
          }
        },
        {
          path: '/roles',
          name: 'roles',
          component: () => import('./components/jurisdiction/roles.vue'),
          meta: {
            bread: ['权限管理', '角色列表']
          }
        },
        {
          path: '/rights',
          name: 'rights',
          component: () => import('./components/jurisdiction/rights.vue'),
          meta: {
            bread: ['权限管理', '权限列表']
          }
        },
        {
          path: '/orders',
          name: 'orders',
          component: () => import('./components/order/orders.vue'),
          meta: {
            bread: ['订单管理', '订单列表']
          }
        },
        {
          path: '/goods',
          name: 'goods',
          component: () => import('./components/shop/goods.vue'),
          meta: {
            bread: ['商品管理', '商品列表']
          },
        },
        {
          // 添加商品
          path: '/add',
          name: 'addgood',
          component: () => import('./components/shop/addgoods.vue'),
          meta: {
            bread: ['商品管理', '添加商品']
          }
        },
        {
          path: '/params',
          name: 'params',
          component: () => import('./components/shop/params.vue'),
          meta: {
            bread: ['商品管理', '分类参数']
          }
        },
        {
          path: '/categories',
          name: 'categories',
          component: () => import('./components/shop/categories.vue'),
          meta: {
            bread: ['商品管理', '商品分类']
          }
        },

      ]
    }
  ]
})
